<template>
	<view class="main">
		<scroll-view scroll-y='true'>
			<view class="po_main">
				<view :style="'padding-top:'+(demo.height+demo.top+10)+'px'">
					<head1 class="nav_top"
						:style="'height:' +  demo.height + 'px;' + 'padding-top:' + demo.top + 'px;padding-bottom:10px'"
						:nav="title">
					</head1>
				</view>
				<view class="index_line"></view>
				<view class="positiondetail">
					<view class="position_recommendation_bottom">
						<view class="prb_top dis_flex">
							<view class="prb_top_left dis_flex">
								<text>{{dataMain.postType}}</text>
								<image src="../../static/icon/tuijian.png" mode="" />
							</view>
						</view>
						<view class="prb_center dis_flex">
							<view class="prb_center_left dis_flex">
								<!-- <text>{{dataMain.money}}</text> -->
								<text>{{dataMain.backgroundName}}</text>
								<text>{{dataMain.educationName}}</text>
							</view>
							<text class="tit">{{dataMain.salaryName}}</text>
						</view>
						<view class="prb_bottom ">
							<view class="prb_bottom_left ">
								<image :src="webImgUrl+dataMain.companyCard" mode="" />
								<text>{{dataMain.companyName}}</text>
							</view>
							<view class="prb_bottom_per ">
								<view>
									<text>招聘人数：</text>
									<text>{{dataMain.number}}</text>
								</view>
								<text>{{dataMain.reviewTime}}</text>
							</view>
						</view>
					</view>
				</view>
				<view class="positiondetailmain">
					<view class="tit">
						<text @click="tit_click(0)" :class="tit_show==0?'tit_active':''">职位描述</text>
						<!-- <text @click="tit_click(1)" :class="tit_show==1?'tit_active':''">企业画像</text> -->
						<text @click="tit_click(2)" :class="tit_show==2?'tit_active':''">其他岗位</text>
						<view class="tit_line"></view>
					</view>
					<view class="tit_main" v-show="tit_show==0">
						<view class="biaoti">
							<text style="font-size: 28rpx;font-weight: 700;color: #49b3af;">岗位职责：</text>
							<view class="content">
								<view v-text="dataMain.details" style="white-space:pre-wrap;"></view>
							</view>
						</view>
						<view class="biaoti">
							<text style="font-size: 28rpx;font-weight: 700;color: #49b3af;">任职资格：</text>

							<view class="content">
								<view v-text="dataMain.requirement" style="white-space:pre-wrap;"></view>
							</view>
						</view>
						<view class="biaoti">
							<text style="font-size: 28rpx;font-weight: 700;color: #49b3af;">福利待遇：</text>

							<view class="content">
								<view v-text="dataMain.welfare" style="white-space:pre-wrap;">
								</view>
							</view>
						</view>
						<view class="tit_main_btn" @click="send">
							<text>立即投递</text>
						</view>
					</view>
					<!-- // 3cb7b7 -->
					<!-- <view class="tit_main" v-show="tit_show==1">
						<view style="margin-top: 91rpx;height: 200rpx;text-align: center;">
							暂无数据
						</view>
						<view class="biaoti">
							公司简介：
							<view class="content">
								<view>
									1.内容填充内容填充内容填充内容填充内容填充内容填充内容填充内容填充
								</view>
							</view>
						</view>
						<view class="biaoti">
							公司历程：
							<view class="content">
								<view>
									1.内容填充内容填充内容填充内容填充内容填充内容填充内容填充内容填充
								</view>
							</view>
						</view>
					</view> -->
					<view class="tit_main" v-show="tit_show==2">
						<view class="other_work" v-for="(item,index) in otherPosition" :key='index'
							@click="posDetail(item)">
							<view class="position_recommendation_bottom">
								<view class="prb_top dis_flex">
									<view class="prb_top_left dis_flex">
										<text>{{item.postType}}</text>
									</view>
									<text class="tit">{{item.salary}}</text>
								</view>
								<view class="prb_center dis_flex">
									<view class="prb_center_left dis_flex">
										<text>{{item.background}}</text>
										<text>{{item.education}}</text>
									</view>
									<text>{{item.reviewTime}}</text>
								</view>

							</view>
						</view>
						<view v-if="otherPosition.length==0"
							style="height: 200rpx;line-height: 200rpx;text-align: center;color: #999999;">{{meishuju}}
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import head1 from '../../common/head/head'
	export default {
		components: {
			head1
		},
		data() {
			return {
				webImgUrl: '',
				active_img: true,
				tit_show: 0,
				meishuju: '暂无数据',
				sc_imgurl: '../../static/icon/shoucang.png',
				title: '职位详情',
				demo: {
					top: '',
					height: ''
				},
				searchForm: {
					type: "",
					search: '',
					currentPage: 1,
					pageSize: 10,
					userId: ''
				},
				otherPosition: [],
				titList: [],
				dataMain: {},
				follow: '', //是否收藏,
				sendData: {
					userId: '',
					target: 'findrt',
					targetId: ''
				},
				companyName: '',
				companyId: ''
			}
		},
		onLoad(option) {
			// 当前职位id存储在本地，等实名后返回详情的时候使用
			uni.setStorageSync('positionId', option.id)
			this.follow = option.follow
			this.sendData.targetId = option.id //详情id
			this.getDetail(option.id)
		},
		computed: {
			userid() {
				return this.$store.state.userId
			}
		},
		created() {
			this.webImgUrl = this.$webUrl
			const demo = uni.getMenuButtonBoundingClientRect()
			this.demo.top = demo.top
			this.demo.height = demo.height
			this.sendData.userId = this.userid //用户id
			this.searchForm.userId = this.userid //用户id

		},
		methods: {
			// 强制刷新、重新加载页面
			test() {
				this.$forceUpdate()
			},
			posDetail(item) {
				this.follow = item.follow
				this.sendData.targetId = item.recruitId //详情id
				this.getDetail(item.recruitId)
				this.tit_show = 0
			},
			getDetail(id) {
				this.$myResquest.recruitDetail({
					recruitId: id
				}).then(res => {
					if (res.data.code == 200) {
						this.dataMain = res.data.data
						this.companyName = res.data.data.companyName
						this.companyId = res.data.data.companyId
					}
				})
			},
			// 	其他职位信息
			getSearch(data) {
				console.log(this.sendData.targetId)
				this.$myResquest.getRecruitSearch(data).then(res => {
					if (res.data.code == 200) {
						// 过滤当前职位显示其他职位
						let dataNew = []
						for (let i = 0; i < res.data.data.length; i++) {
							if (this.sendData.targetId != res.data.data[i].recruitId) {
								dataNew.push(res.data.data[i])
							}
						}
						this.otherPosition = dataNew

					}
				})
			},
			collZWTJ(index) {
				if (this.active_img) {
					this.sc_imgurl = '../../static/icon/shoucang2.png'
					this.active_img = !this.active_img
					uni.showToast({
						title: "关注成功"
					})
				} else {
					this.sc_imgurl = '../../static/icon/shoucang.png'
					this.active_img = !this.active_img
					uni.showToast({
						title: "取消关注"
					})
				}
			},
			tit_click(index) {
				this.searchForm.companyName = this.companyName
				this.searchForm.companyId = this.companyId
				this.tit_show = index
				this.getSearch(this.searchForm)

			},
			// 投递
			send() {
				// 获取提示信息字典
				let tishiData = this.$store.state.tishiInfo.data.jobDet
				let userIsReal = uni.getStorageSync('userIsReal')

				if (userIsReal == '未实名') {
					uni.showToast({
						title: '请先去实名认证!',
						icon: 'none'
					})
					setTimeout(function() {
						uni.navigateTo({
							url: '../../common/realName/nowReal?title=投递实名'
						})
					}, 1000)
				} else {
					// uni.request({
					// 	url: 'https://www.chuanjianbao.com/buildtreasure/recruit/concat',
					// 	method: 'POST',
					// 	header: { //请求头可自定义
					// 		'Content-Type': 'application/json;charset=UTF-8',
					// 		// 'X-Access-Token': TOKEN
					// 		'Cookie': 'JSESSIONID=' + uni.getStorageSync('sessionId')
					// 	},
					// 	data: this.sendData,
					// 	success(res) {
					// 		console.log(tishiData)
					// 		if (res.data.code == 200) {
					// 			uni.showModal({
					// 				title: '温馨提示',
					// 				showCancel: false,
					// 				content: tishiData,
					// 				success(res) {
					// 					if (res.confirm) {} else if (res.cancel) {}
					// 				}
					// 			})
					// 		} else {
					// 			// uni.showToast({
					// 			// 	title: res.data.msg,
					// 			// 	icon: 'none'
					// 			// })
					// 		}
					// 	}
					// })
					this.$myResquest.recruitConcat(this.sendData).then(res => {
						if (res.data.code == 200) {
							uni.showModal({
								title: '温馨提示',
								showCancel: false,
								content: tishiData,
								success(res) {
									if (res.confirm) {} else if (res.cancel) {}
								}
							})
						} else {

						}
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		position: fixed;
		top: 0;
		z-index: 9;
		height: 100%;
		width: 100%;
		background: #ffffff;
		overflow: auto;

	}

	.po_main {
		height: 100%;

		.positiondetail,
		.other_work {
			padding: 24rpx;
			box-sizing: border-box;

			.position_recommendation_bottom {
				width: 100%;
				// min-width: 351px;
				height: 256rpx;
				padding: 0 16rpx;
				margin-top: 26rpx;
				box-sizing: border-box;
				background: #ffffff;
				border-radius: 10rpx;
				box-shadow: 0px 0px 18rpx 0px rgba(0, 0, 0, 0.1);

				&:first-child {
					margin-top: 0;
				}

				.prb_top {
					height: 80rpx;

					.prb_top_left {
						text {
							font-size: 32rpx;
							font-family: Adobe Heiti Std, Adobe Heiti Std-R;
							font-weight: R;
							text-align: left;
							color: #49b3af;
						}

						image {
							margin-left: 14rpx;
							width: 46rpx;
							height: 36rpx;
						}
					}

					image {
						width: 36rpx;
						height: 34rpx;
					}
				}

				.prb_center {
					.tit {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #f46969;
					}

					.prb_center_left {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #999999;

						text {
							text-align: center;
							min-width: 112rpx;
							height: 40rpx;
							margin: 0 4rpx;
							line-height: 40rpx;
							box-sizing: content-box;
							background: #f2f2f2;
							border-radius: 6rpx;
						}
					}
				}

				.prb_bottom {
					margin-top: 30rpx;

					.prb_bottom_left {
						display: flex;
						align-items: center;

						image {
							width: 50rpx;
							height: 50rpx;
							margin-right: 14rpx;
							border-radius: 50%;

							text {
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Medium;
								font-weight: 500;
								text-align: left;
								color: #999999;
							}
						}
					}

					.prb_bottom_per {
						display: flex;
						justify-content: space-between;

						view {
							display: flex;
							align-items: center;
							padding-left: 66rpx;
							box-sizing: border-box;

							.line {
								display: block;
								height: 26rpx;
								width: 2rpx;
								background: #999999;
								margin: 0 20rpx;
							}
						}
					}

					text {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #999999;
					}
				}
			}

		}

		.positiondetailmain {
			padding: 40rpx;
			box-sizing: border-box;

			.tit {
				display: flex;
				position: relative;
				height: 80rpx;

				.tit_line {
					position: absolute;
					top: 63rpx;
					left: 0;
					height: 2rpx;
					width: 100%;
					background: #c6c8d5;
					z-index: -1;
				}

				text {
					display: block;
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: left;
					color: #999999;
					margin-left: 80rpx;
				}

				:first-child {
					margin-left: 0;
				}
			}



			.tit_main {
				.biaoti {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Bold;
					font-weight: 500;
					text-align: left;
					color: #333333;

					.content {
						padding: 15rpx 76rpx 15rpx 10rpx;
						box-sizing: border-box;

						view {
							line-height: 48rpx;
						}
					}
				}

				.tit_main_btn {
					margin: 0 auto;
					margin-top: 200rpx;
					width: 600rpx;
					height: 88rpx;
					line-height: 88rpx;
					background: #5cd1ce;
					border-radius: 44rpx;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: center;
					color: #ffffff;

				}

				.other_work {
					border-bottom: 2rpx solid #c6c8d5;
					padding: 0 10rpx;
					box-sizing: border-box;

					.position_recommendation_bottom {
						height: 156rpx;
						box-shadow: none;
						padding: 0;

						.prb_center {
							.prb_center_left {
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Medium;
								font-weight: 500;
								text-align: left;
								color: #999999;
							}
						}
					}

					.tit {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #f46969;
					}
				}
			}

			.tit_active {
				color: #49b3af !important;
				// ::after {
				// 	content: '';
				// 	width: 65%;
				// 	height: 2rpx;
				// 	display: block;
				// 	margin: 28rpx auto;
				// 	z-index: 999;
				// 	border-bottom: 2rpx solid #333333;
				// }

			}
		}
	}
</style>
